import time
from appium.webdriver.common.appiumby import AppiumBy
from base.base_page import find_and_do, press_keycode, switch_to_context, perform_touch_action, perform_swipe_sequence


class Auto_case:
    def __init__(self, driver):
        self.driver = driver

    def test_case(self):
        driver = self.driver

        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/ivNext")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/stv_start")
        time.sleep(1)
        find_and_do(driver, 'send_keys', AppiumBy.ID, "joyhub.net.joyhub:id/etEmail", "ypcna@q")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/llCode")
        time.sleep(1)
        find_and_do(driver, 'send_keys', AppiumBy.ID, "joyhub.net.joyhub:id/etCode", "998877")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/cbAgreeOld")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/cbAgreePrivate")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/btnRegisterOrLogin")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "com.android.permissioncontroller:id/permission_allow_foreground_only_button")
        time.sleep(1)
        find_and_do(driver, 'click', AppiumBy.ID, "joyhub.net.joyhub:id/btn_video2")
        time.sleep(1)
        # 点击坐标 (279, 1132)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 279, 'y': 1132},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
        # 点击坐标 (795, 1132)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 795, 'y': 1132},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
        # 点击坐标 (292, 1553)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 292, 'y': 1553},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
        # 点击坐标 (785, 1553)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 785, 'y': 1553},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
        # 点击坐标 (265, 2000)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 265, 'y': 2000},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
        # 点击坐标 (753, 1991)
        perform_touch_action(driver, [
            {'type': 'move_to', 'x': 753, 'y': 1991},
            {'type': 'pointer_down'},
            {'type': 'pause', 'duration': 0.1},
            {'type': 'pointer_up'}
        ])
        time.sleep(1)
